<?php

error_reporting(E_ALL);
ini_set("display_errors", 0);
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/libs.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/constants/Constants.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/portal/DAO/AccountDAO_Class.php';

header('Content-type: text/html; charset=utf-8');
include dirname(__FILE__) . '/view/menu/index.php';
if ($_SESSION['utype'] != 'ADMIN') {
    $accountDAO = new AccountDAO();
    if (isset($_POST['username']) || isset($_POST['password'])) {
        $username = $_POST['username'];
        $password = $_POST['password'];
        $accountDAO->authentication($username, $password);
        header("location:/");
    }
    $smarty->display("account/login.tpl");
} else {
    $smarty->display("menu/menu.tpl");
}
?>
